package com.mdd.product.controller;

import com.mdd.common.aop.Log;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.validate.IdValidate;
import com.mdd.product.service.ICategoryEmploymentService;
import com.mdd.product.validate.category.CategoryEmploymentCreateValidate;
import com.mdd.product.validate.category.CategoryEmploymentUpdateValidate;
import com.mdd.product.vo.category.CategoryEmploymentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("api/employment")
@Api(tags = "行业类别管理")
public class CategoryEmploymentController {

    @Resource
    ICategoryEmploymentService iCategoryEmploymentService;

    @GetMapping("/list")
    @ApiOperation(value="行业类别列表")
    public AjaxResult<List<CategoryEmploymentVo>> list() {
        return AjaxResult.success(iCategoryEmploymentService.list());
    }

    @Log(title = "行业类别新增")
    @PostMapping("/add")
    @ApiOperation(value="行业类别新增")
    public AjaxResult<Object> add(@Validated @RequestBody CategoryEmploymentCreateValidate createValidate) {
        iCategoryEmploymentService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "行业类别编辑")
    @PostMapping("/edit")
    @ApiOperation(value="行业类别编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody CategoryEmploymentUpdateValidate updateValidate) {
        iCategoryEmploymentService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "行业类别删除")
    @PostMapping("/del")
    @ApiOperation(value="行业类别删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iCategoryEmploymentService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
